<?php
/*
Plugin Name: Data Manip
Plugin URI: http://wordpress.org/extend/plugins/hello-dolly/
Description: This is a test plugin so I can lean what to do!
Author: Tyler Wiest
Version: 1.1
Author URI: http://www.jtwventures.com
License: GPLv2
*/

// Include the Widget Information 
include 'data_widget.php';


// Create Custom Meta Data Box on Post Pages
// Add ACtion to create Meta_box
add_action( 'add_meta_boxes', 'jtw_data_meta_create');

// Register Custom Meta Box
function jtw_data_meta_create() {
	add_meta_box('jtw-data-meta', 'Add Data', 'jtw_data_meta_function', 'post', 'normal', 'high');
}

function jtw_data_meta_function( $post ) {
	// retreive meta values if they exist
	$jtw_title_meta = get_post_meta( $post->ID, '_jtw_title_meta', true);
	$jtw_data_meta = get_post_meta( $post->ID, '_jtw_data_meta', true);
	?>
	<p>Title: <input class="widfat" name="jtw_title_meta"
			type="text" value="<?php echo esc_attr( $jtw_title_meta ); ?>" /></p>
	<p>Data: <input class="widfat" name ="jtw_data_meta"
			type="text" value="<?php echo esc_attr( $jtw_data_meta ); ?>" /></p>
	<?php
}

// Hook to save the meta data
add_action( 'save_post', 'jtw_data_save_meta');

// Function to save the meta data
function jtw_data_save_meta( $post_id ) {
	// verify the meta data is set
	if ( isset($_POST['jtw_title_meta']) or isset($_POST['jtw_data_meta'])) {
		// save meta data
		update_post_meta($post_id, '_jtw_title_meta', esc_attr( $_POST['jtw_title_meta']));
		update_post_meta($post_id, '_jtw_data_meta', esc_attr( $_POST['jtw_data_meta']));
	}
}



// I want to be able to enter in custom meta info into a post, widget or use a short code to help.
?>